package org.meeting.radish.service.impl;

import lombok.extern.slf4j.Slf4j;
import org.meeting.radish.entity.Question;
import org.meeting.radish.mapper.QuestionMapper;
import org.meeting.radish.service.QuestionService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Slf4j
@Service
public class QuestionServiceImpl implements QuestionService {

    @Resource
    QuestionMapper questionMapper;

    @Override
    public Integer addQuestion(Question question) {
        Integer integer = questionMapper.addQuestion(question);
        log.info("题目插入成功");
        return integer;
    }

    @Override
    public Integer deleteQuestion(Integer qid) {
        Integer integer = questionMapper.deleteQuestion(qid);
        log.warn("id为{}的题目已删除", qid);
        return integer;
    }

    @Override
    public Integer updateQuestion(Question question) {
        Integer integer = questionMapper.updateQuestion(question);
        log.info("id为{}的题目已修改", question.getQid());
        return integer;
    }

    @Override
    public Question queryQuestionByQid(Integer qid) {
        Question question = questionMapper.queryQuestionByQid(qid);
        log.info("id为{}的题目已查询", qid);
        return question;
    }


    @Override
    public List<Question> queryOnceQuestion(Integer uid) {
        List<Question> questions = questionMapper.queryUserQuestionByUid(uid);
        log.info("用户{}的答题详情已查询", uid);
        return questions;
    }
}
